import os

from cvsanaly_fork import generationsml
from db.mydatabase import MyDatabase
from settings import *

OUTPUT_MASTER_DIR = os.path.join(OUTPUT_DIR,'ml/')

class GenerationsScript:

    def __init__ (self, user = None, password = None, dbname = None, output_dir = None):

        self.output_dir = output_dir

        self.db = MyDatabase()
        self.db.user = user
        self.db.password = password
        self.db.name = dbname

        self.db.connect()

        
    def run (self):

        gens_directory = os.path.join(self.output_dir,self.db.name)
        if not os.path.isdir (gens_directory):
            os.makedirs (gens_directory)

        period = generationsml.periodSlots(20)
        gen = generationsml.generations (self.db, gens_directory, period)


if '__main__' == __name__:

    gs = GenerationsScript(mysql_user,mysql_password,"mlstats",OUTPUT_MASTER_DIR)
    gs.run()
